package com.turing.data.scripts.contract.filter

import com.turing.data.engine.utils.ScriptsUtils
import com.turing.data.vo.out.review.DependParamsVO
import com.turing.data.vo.out.review.TaskElementVO
import org.springframework.util.CollectionUtils

class TemporaryOpenFrequencyExplaination_30187_10_filter {

    static List< TaskElementVO.DrawResultVO > doConvert(DependParamsVO dependParams){

        String REGEX_EXPLAINATION = /.*特别地，.*/
        String REGEX_EXPLAINATION_1 = /.*设立临时开放日.*/

        def textPathMap = dependParams.textPathMap

        List<TaskElementVO.DrawResultVO > trueValueSet = new ArrayList<>()
        List<TaskElementVO.DrawResultVO > resultVOs = ScriptsUtils.tryInitResult(dependParams)
        if (resultVOs!=null && resultVOs.size()>0) {
            for (int i = 0; i < resultVOs.size(); i++) {
                def resultVO = resultVOs.get(i)
                def text = resultVO.text
                if ( text =~ REGEX_EXPLAINATION ||  text =~ REGEX_EXPLAINATION_1 ){
                    resultVO.businessValue = text
                    trueValueSet.add(resultVOs.get(i))
                    return trueValueSet
                }
            }
        }
        if(!CollectionUtils.isEmpty(resultVOs) && resultVOs.size()>2){
            trueValueSet.add(resultVOs[0])
            return trueValueSet
        }
        return  resultVOs
    }

}
